<!DOCTYPE html>

<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p id="p1"></p>
		<button onclick="sum()">求和</button>
		<button onclick="rev()">反转</button>
		<button onclick="sort()">排序</button>
		<button onclick="hoh()">包含100</button>
		<button onclick="add()">添加</button>
		<p id="p2"></p>
		<script>
			document.getElementById("p1");
			document.getElementById("p2")
			var a=[12,46,9,26,100,69,26,5];
			p1.innerHTML=a;
			function sum(){
				var sum=0
				for(var i=0;i<a.length;i++){
					sum=sum+a[i];
				}
				p2.innerHTML=sum;
			}
			function rev(){
				var b=a.reverse();
				p2.innerHTML=b;
			}
			function sort(){
				var b=a.sort(
					function(a,b){
					}
				);
				p2.innerHTML=b;
			}
			function hoh(){
				for(var i=0;i<a.length;i++){
					if(a[i]==100){
						p2.innerHTML="100在第"+(i+1)+"个";
					}
				}
			}
			function add(){
				var n=parseInt(Math.random()*1000);
				var m=parseInt(Math.random()*1000);
				var j=parseInt(Math.random()*1000);
				a.splice(2,0,n,m,j);
				p2.innerHTML=a;
			}
		</script>
	</body>
</html>
